fix: keep orphaned linked memories visible in the timeline - #260
Conversation
handleListMemories grouped memory-prompt pairs by id and then dropped any pair missing one side. A memory whose linked prompt was deleted (or captured with prompts off) vanished from /api/memories even though it still existed in the shard and search. One-sided pairs now fall back to standalone items.
lindixu6-hash
left a comment
There was a problem hiding this comment.
Reviewed the timeline pairing path and the new regression coverage. The change preserves complete memory/prompt ordering and moves only one-sided pairs into the existing timestamp-sorted standalone list.
Local verification on c7b705fe6073517aa2611ea118f57d8dc1d1a232: targeted orphan/pair tests 2 pass, 0 fail; bun run typecheck passed; bun run format:check passed. The sandbox reported cleanup restrictions for temporary directories after the commands completed, so those restrictions did not affect the assertions or static checks.
|
Post-merge validation for exact merge commit |
Bug
handleListMemories(the Web UI timeline endpoint) grouped memory-prompt pairs by id and then dropped any pair missing one side. A memory whose linked prompt was deleted (DELETE /api/prompts/:idwithout cascade), expired, or never captured, vanished from/api/memorieseven though it still existed in the shard and was still reachable via/api/search. Same for prompts whose linked memory was gone.Root cause
In
handleListMemories:Items that referenced a missing counterpart were neither in
pairsnor added tostandalone.Fix
One-sided pairs now fall back to
standalone, so orphaned linked memories/prompts still render, unlinked, in the timeline. Complete pairs still render together.Tests
memory timeline listing > keeps memories whose linked prompt is missing from the timeline— reproduces the drop (fails before the fix, passes after)memory timeline listing > renders linked memory-prompt pairs together in the timeline— guards the pairing pathVerification
tsc --noEmitcleanmain(pre-existing flakes: onnxruntime-resolve shim, plugin-loader contract timeout, turso-shard recreate timeout, config parallel). No new failures.